<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
// +----------------------------------------------------------------------+
// | Treacle PHP Framework Version 0.10                                   |
// +----------------------------------------------------------------------+
// | Copyright (c) 2007 Treacle.cn All rights reserved.					  |
// +----------------------------------------------------------------------+
// | Licensed under the Apache License, Version 2.0 (the 'License');      |
// | you may not use this file except in compliance with the License.     |
// | You may obtain a copy of the License at                              |
// | http://www.apache.org/licenses/LICENSE-2.0                           |
// | Unless required by applicable law or agreed to in writing, software  |
// | distributed under the License is distributed on an 'AS IS' BASIS,    |
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
// | implied. See the License for the specific language governing         |
// | permissions and limitations under the License.                       |
// +----------------------------------------------------------------------+
// | Author: BoPo <ibopo@126.com>										  |
// +----------------------------------------------------------------------+
/**
 * 应用文件
 *
 * @author BoPo <ibopo@126.com>
 * @link http://www.treacle.cn/
 * @copyright Copyright &copy; 2007 Treacle
 * @license http://www.treacle.cn/license/
 * @version $Id $
 */

require(BASEPATH.'Treacle'.EXT);
require(BASEPATH.'TController'.EXT);
require(BASEPATH.'Configure'.EXT);
require(BASEPATH.'TRouter'.EXT);
require(BASEPATH.'template/TTemplate'.EXT);
require(BASEPATH.'exception/TException'.EXT);

Configure::initialize();
Treacle::initErrorHandlers();

$RTR	= new TRouter();
$class	= $RTR->fetch_class();

if (!file_exists(APPPATH.'controllers/'.$class.EXT))
{
	throw new THttpException(404,'Not Found Page');
}

include_once(APPPATH.'controllers/'.$class.EXT);

if (!class_exists($class) OR $class == 'TController' OR substr($class, 0, 1) == '_')
{
	throw new THttpException(404,'Not Found Page');
}

$App = new $class();
$App->run();

if ($App->db){$App->db->close();}
/*
+--------------------------------------------------------------------------
|   Last Modified By BoPo
|   Date: Wed Oct 03 14:43:30 CST 2007
+--------------------------------------------------------------------------
*/
?>